package tag28_19_08.serial;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;


public class Ser04_SerializableTeil {
	
	static class Fruit implements Serializable {
//	static class Fruit{	
		int size;
	}
	
	static class Banana extends Fruit {
		int color;
		
		public String toString() { return "size = " + size + ", color = " + color; }
	} 

	public static void main(String[] args) throws Exception {

		Banana b1 = new Banana();
		b1.color = 22;
		b1.size = 678;
		
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("banana"));
		oos.writeObject(b1);
		oos.close();
		
		System.out.println("Serialisiert: " + b1);
		
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream("banana"));
		Banana b2 = (Banana)ois.readObject();
		ois.close();
		
		System.out.println("Deserialisieret: " + b2);

	} //end of main

}
